<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('username')->unique()->comment('用户名');
            $table->string('nickname')->nullable()->comment('昵称');
            $table->string('email')->nullable()->unique()->comment('邮箱');
            $table->string('phone')->nullable()->unique()->comment('手机号');
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('password')->comment('密码');
            $table->tinyInteger('status')->default(1)->comment('状态：1-启用，0-禁用');
            $table->unsignedBigInteger('dept_id')->nullable()->comment('部门ID');
            $table->string('remark')->nullable()->comment('备注');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();

            $table->index('dept_id');
            $table->index('status');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('users');
    }
};

